const {
  menuMapRepair
} = require('../../../config/menu')
const {
  getUserBaseInformation
} = require('../../../utils/strorage')
const { getEventData } = getApp();
function getMenu() {
  const userInfo = getUserBaseInformation()
  let approvalSupplementaryWorkOrder = 0
  if (userInfo) {
    approvalSupplementaryWorkOrder = userInfo.approvalSupplementaryWorkOrder
  }

  return menuMapRepair.filter(item => {
    if (item.approvalSupplementaryWorkOrder === 1) {
      return item.approvalSupplementaryWorkOrder === approvalSupplementaryWorkOrder;
    }
    return true
  })
}
Component({
  options: {
    addGlobalClass: true
  },
  data: {
    indexMenuList: getMenu(),
    activeTabs: 'home'
  },

  lifetimes: {
    attached() {
      this.setData({
        indexMenuList: getMenu()
      })
    }
  },

  methods: {
    onTabsChange(event) {
      this.setData({
        activeTabs: event.detail
      })
    },

    handleMenuIconClick(event) {
      const { data } = getEventData(event)
      this.triggerEvent('clickIcon', data)
    }
  }
})
